package model;

import java.awt.Graphics;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;


public class Goal extends GameObject
{
        private boolean visible;
        private int duration;
        
        private final int DUR = 10000;
        
        public Goal()
        {
                super();
                xDim = 120;
                yDim = 20;
                visible = true;
                duration = 0;
                
                filename = "GoalUser.jpg";
                
                try{
                        image = ImageIO.read(new File(filename));
                } catch(IOException e){ 
                }
        }
        
        public Goal(Goal goal)
        {
                super();
                xDim = 120;
                yDim = 20;
                visible = true;
                duration = 0;
                
                this.filename = goal.getFilename();
                
                try{
                        image = ImageIO.read(new File(filename));
                } catch(IOException e){ 
                }
        }
        
        public Goal(String filename)
        {
                super();
                xDim = 120;
                yDim = 20;
                visible = true;
                duration = 0;
                
                this.filename = filename;
                
                try{
                        image = ImageIO.read(new File(filename));
                } catch(IOException e){ 
                }
        }
        
        public boolean getVisibility()
        {
                return visible;
        }
        
        public void setDuration()
        {
                duration = DUR;
                
                if(duration > 0)
                        visible = false;
                
                if(duration <= 0)
                        visible = true;
        }
        
        public int getDuration()
        {
                return duration;
        }
        
        public void tick()
        {
                if(duration > 0)
                {
                        duration--;
                        visible = false;
                }
                        
                
                if(duration <= 0)
                        visible = true;
        }
        
        public void draw(Graphics page)
        {
                if((visible) && (duration <= 0))
                        page.drawImage(image, (int)getX(), (int)getY(), null);
        }
        
        public void update()
        {
                tick();
        }
        
        
}